<template>
	<view :class="{'my-tabs':true,'space-between':formatBe}">
		<view v-for="(item,index) in getModelData" :key="index" :class="{'tab-item':true,'active':formatIndex==index}" @tap="tap(index)">
			{{item.label}}
		</view>
	</view>
</template>

<script>
	export default {
		props: ['modelData', 'initIndex'],
		data() {
			return {

			}
		},
		computed: {
			getModelData() {
				return this.modelData
			},
			formatBe() {
				return this.modelData ?
					this.modelData.length > 4 ? true : false :
					false
			},
			formatIndex() {
				return this.initIndex
			}
		},
		methods: {
			tap(index) {
				this.$emit("change", index);
			}
		}
	}
</script>
<style lang='scss'>
	.my-tabs {
		background-color: #ffffff;
		height: 75upx;
		font-size: 38upx;
		display: flex;
		box-sizing: border-box;
		/* border-top: 2upx solid #dddddd;
		border-bottom: 2upx solid #dddddd; */
		width: 100%;
		overflow-x: auto;
		align-items:center;

		.tab-item {
			text-align: center;
			font-weight: 700;
			margin-left:45upx;
			padding-bottom: 4upx;
		}

		.tab-item.active {
			position: relative;
			color: #2E77ED;
		}
		.tab-item.active::after {
			content: "";
			position: absolute;
			bottom: 0;
			left: 50%;
			transform: translateX(-50%);
			width: 35%;
			border-bottom: 6upx solid #2E77ED;
			animation: test ease 1 1.5s;
		}
	
	}

	.my-tabs.space-between {
		justify-content: space-between;
	}

	@keyframes test {
		0% {
			width: 35%
		}

		50% {
			width: 50%
		}

		100% {
			width: 35%
		}
	}
</style>
